<template>
	<view class="shop page bgf6 p15">
		<view v-for="(item,index) in list" :key="index" @click="clickDetail(item)" class="flex flexC bgff r7 mb12 px10 py22">
			<image class="w82 r6" :src="item.logo" mode="aspectFill"></image>
			<view class="flex1 ml12">
				<view class="flex flexC flexB">
					<text class="bold6 ellipsis1">{{item.name}}</text>
					<text class="arrowR mr4"></text>
				</view>
				<view class="mb14 mt6">{{item.address}}</view>
				<view class="fs13">{{item.mobile}}</view>
			</view>
		</view>
		
		<view class="add r50 bged aliC" @click="clickAdd">添加</view>
		<uni-popup ref="pop" type="bottom">
			<view class="popup-content2">
				<button class="popup-btn button" @click="look" >查看酒店二维码</button>
				<button class="popup-btn button" @click="clickDel">删除</button>
				
				<view class="popup-btn" @click="$refs.pop.close()">取消</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				current:null,
				code:''
			};
		},
		
		onLoad() {
		
		},
		onShow() {
			this.getList();	
		},
		methods:{
			
			look(){
				
				this.$refs.pop.close();
				let param = {
					id:this.current.id,
					shop_id:uni.getStorageSync("shop_id")
				};
				let that = this;
				this.$api.lookCode(param).then(res => {
							
					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.code = res.data;
						let image = Array();
						image.push(that.code);
						uni.previewImage({
							urls: image,
						});
					} else {
							
					}
				})
			},
			
			
			
			clickDel(){
				this.$refs.pop.close();
				
				let param = {
					id:this.current.id
				};
				let that = this;
				this.$api.hotelDel(param).then(res => {
							
					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.getList();
					} else {
							
					}
				})
				
			},
			
			clickDetail(item){
				
				this.current = item;
				this.$refs.pop.open();
			},
			
			clickAdd(){
			  uni.navigateTo({
			  	url:'/other/hotel/add'
			  })	
			},
			
			getList(){
				let param = {
				
				};
				let that = this;
				this.$api.hotelList(param).then(res => {
							
					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.list = res.data;
					} else {
							
					}
				})
			},
			
		
		}
	}
</script>

<style lang="scss" scoped>
.shop {
	.w82 {width: 164rpx;height: 164rpx;}
	.ellipsis1 {max-width: 400rpx;}
	
	.add {
		position: fixed;
		bottom: 100px;
		right: 10rpx;
		width: 80rpx;
		height: 80rpx;
		line-height: 80rpx;
		border: 2rpx solid #FD449B;
	}
}

	.popup-content2 {
		background: #FFFFFF;

		.popup-btn {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			border-bottom: 1px solid #f5f5f5;
			background: #FFFFFF;
		}

		.button {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			border-bottom: 1px solid #f5f5f5;
			background: #FFFFFF;
			font-size: 11pt;
		}

		button::after {
			border: none;
		}

		.pt20 {
			border-bottom: 20rpx solid #f5f5f5;
		}
	}
</style>
